#include "Tool.h"

namespace util{
    namespace tool{
        void PrintError(
            DWORD  dwFlags,
            LPCVOID lpSource,
            DWORD   dwMessageId,
            DWORD   dwLanguageId,
            va_list *Arguments)
        {
            if(dwMessageId == 0)
                return;
            std::cout << dwMessageId << ':' << std::endl;
            if(FormatMessage(
                dwFlags,
                lpSource,
                dwMessageId,
                dwLanguageId,
                lpErrorMessageBuffer,
                bufferSize,
                Arguments
            )){
                COUT << lpErrorMessageBuffer << std::endl;
            }
            else{
                std::cout << "failed to get formated error message" << std::endl;
            }

        }

        void PrintError(){
            PrintError(
                FORMAT_MESSAGE_ALLOCATE_BUFFER
                | FORMAT_MESSAGE_FROM_SYSTEM
                | FORMAT_MESSAGE_IGNORE_INSERTS,
                NULL,
                GetLastError(),
                MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
                NULL
            );
        }
    }
}